package com.jetinno.eva_app;

import android.app.Application;
import android.os.Build;

import com.jetinno.eva.EvaManager;
import com.jetinno.eva.bean.EvaCanisterBean;
import com.jetinno.eva.bean.EvaOrderBean;
import com.jetinno.eva.bean.EvaProductBean;
import com.jetinno.eva.callback.EvaCallBack;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import timber.log.Timber;

/**
 * Created by zhangyuncai on 2024/11/15.
 * 描述：实现了jetinno库功能
 */
public class EvaIml {
    public static void init(Application application) {

        EvaManager.getInstance().init(application);
        EvaManager.getInstance().setEvaCallBack(new EvaCallBack() {
            @Override
            public boolean getMdbReplenish() {
                return false;
            }

            @Override
            public List<EvaOrderBean> getAllOrderList() {
                List<EvaOrderBean> list = new ArrayList<>();
//                for (ProductInfo productInfo : OrderDao.getInstance().queryProductInfos()) {
//                    EvaOrderBean bean = new EvaOrderBean();
//                    bean.setPayTypeName(productInfo.getPayType());
//                    bean.setProductAmount(productInfo.getProductAmount());
//                    bean.setProductId(productInfo.getProductId());
//                    bean.setTimestamp(NumberUtil.parseLong(productInfo.getTimestamp()));
//                    list.add(bean);
//                }
                return list;
            }

            @Override
            public String getMachineNum() {
                return "54635";
            }

            @Override
            public String getControlBoardSoftware() {
//                int state44 = SerialDatasHepler.INSTANCE.getState44();
//                int state45 = SerialDatasHepler.INSTANCE.getState45();
                int state44 = 80;
                int state45 = 13;
                String controlBoardSoftware = String.format("%d.%d", state44, state45);//IO版本号 80.29
                return controlBoardSoftware;
            }

            @Override
            public String getMachineName() {
                return "JL300_ESFB_8C";
            }

            @Override
            public List<EvaProductBean> getAllProduct() {
                List<EvaProductBean> list = new ArrayList<>();
//                List<ProductBean> productBeans = ProductDao.getInstance().queryList();
//                for (ProductBean productBean : productBeans) {
//                    EvaProductBean bean = new EvaProductBean();
//                    bean.setProductId(productBean.getProductId());
//                    bean.setEnName(productBean.getEnValue());
//                    bean.setSalePrice(productBean.getSalePrice());
//                    list.add(bean);
//                }
                return list;
            }

            @Override
            public List<EvaCanisterBean> getAllCanister() {
                List<EvaCanisterBean> list = new ArrayList<>();
//                List<CanisterBean> canisterBeans = CanisterDao.getInstance().queryAllCanisterSet();
//                for (CanisterBean canisterBean : canisterBeans) {
//                    EvaCanisterBean bean = new EvaCanisterBean();
//                    bean.setMaterialId(canisterBean.getMaterialId());
//                    bean.setRemain(canisterBean.getRemain());
//                    list.add(bean);
//                }
                return list;
            }

            @Override
            public String getEvaComPath() {
                HashMap<String, String> mSerialMap = new HashMap<>();
                mSerialMap.put("UniWin_M190", "/dev/ttyS1");
                mSerialMap.put("UniWin", "/dev/ttyS4");
                mSerialMap.put("rockchip", "/dev/ttyS7");
                String path = mSerialMap.get(Build.BRAND);
                Timber.i("path:%s", path);
                return path;
//                return "/dev/ttyS7";
            }
        });
    }
}
